//
//  BaseTableViewController.swift
//  LX_weibo
//
//  Created by LTT❤️ on 15/6/24.
//  Copyright © 2015年 LTT. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController ,VisitorLoginViewDelegate{
    
   var userLogon = sharedUserAccount != nil
    //var userLogon = false
   var visitorView:VisitorLoginView?
   
    override func loadView() {
        
        print("用户登录\(userLogon)")
        userLogon ? super.loadView() : setupVistorView()
    }
    
    //创建访客视图
    private func setupVistorView(){
        visitorView = VisitorLoginView()
        visitorView?.delegate = self
        view = visitorView
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorRegisterButtonClicked")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登陆", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginButtonClicked")
    }
    
    func visitorRegisterButtonClicked() {
        print("注册")
    }
    func visitorLoginButtonClicked() {
        let vc = OAuthViewController()
        let nav = UINavigationController(rootViewController: vc)
        presentViewController(nav, animated: true, completion: nil)
        
    }
    
    
}
